﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace Kira.Compiler.Bods
{
    [XmlElementMapping("FUNCTION_CALL")]
    public class FunctionCall : BodsExpression
    {

        public String Name
        {
            get { return this.GetAttrbuteValue("name"); }
        }

        public FunctionCallType FunctionCallType
        {
            get { return (FunctionCallType)Enum.Parse(typeof(FunctionCallType), this.GetAttrbuteValue("type"), true); }
        }

        public IEnumerable<BodsExpression> Arguments
        {
            get
            {
                return this.GetElements<BodsExpression>();
            }
        }

        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(this.Name).Append("(");
            bool isFirst = true;
            foreach (var i in this.Arguments)
            {
                if (isFirst)
                {
                    isFirst = false;
                }
                else
                {
                    sb.Append(", ");
                }
                sb.Append(i.ToString());

            }
            sb.Append(")");
            return sb.ToString();
        }

    }

    public enum FunctionCallType
    {
        Di
    }



}
